import { ILoadMapTypeAll } from '@/common';
import { getTenantID } from '@/utils';
import { useEffect } from 'react';

interface useWorkFlowConfigProps {
  currentKey: string; //当前页面标签
  dataInfo: Record<string, any>; //实施详情
  // saveWorkFlowConfig: (config: Record<string, any>) => void; //保存配置数据
  // workFlowConfig: any
}
const useWorkFlowConfig = ({
  currentKey,
  dataInfo,
}: // saveWorkFlowConfig,
// workFlowConfig
useWorkFlowConfigProps) => {
  // useEffect(() => {
  let workInfo: Record<string, any> = {};
  if (dataInfo && dataInfo?.id) {
    // if (currentKey == 'source-tender') {
    //   workInfo['sourceDetailInfo'] = dataInfo;
    //   workInfo['sourceController'] = 'purchaseSourceController';
    //   workInfo['sourceCategory'] = `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1008`;
    //   workInfo['sourceBusinessCategory'] = `${getTenantID()}${ILoadMapTypeAll.TENDERANNOUN_FLOWTYPE}1000`;
    //   workInfo['sourceRevokeState'] = `${getTenantID()}${ILoadMapTypeAll.CURRYOUT_STATE}1003`;
    //   workInfo['sourceCancelState'] = `${getTenantID()}${ILoadMapTypeAll.CURRYOUT_STATE}1001`;
    //   workInfo['sourceOrderType'] = dataInfo?.orderType || `${getTenantID()}${ILoadMapTypeAll.ALLORDER_TYPE}1015`;
    // } else
    // else if (currentKey == 'source-change') {
    //   workInfo['sourceDetailInfo'] = dataInfo;
    //   workInfo['sourceController'] = 'purchaseSourceChangeController';
    //   workInfo['sourceCategory'] = `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1002`;
    //   workInfo['sourceBusinessCategory'] = `${getTenantID()}${ILoadMapTypeAll.CHANGEPURCHASE_METHOD}1000`;
    //   workInfo['sourceRevokeState'] = `${getTenantID()}${ILoadMapTypeAll?.PURCHASE_CHANGEWAY}1000`;
    //   workInfo['sourceCancelState'] = `${getTenantID()}${ILoadMapTypeAll?.PURCHASE_CHANGEWAY}1003`;
    //   workInfo['sourceOrderType'] = dataInfo?.orderType || `${getTenantID()}${ILoadMapTypeAll.ALLORDER_TYPE}1013`;
    //   workInfo['sourceApplyFields'] = { own: 'apply' };
    // }
    if (currentKey == 'source-clarify') {
      workInfo['sourceDetailInfo'] = dataInfo;
      workInfo['sourceController'] = 'purchaseSourceClarifyController';
      workInfo['sourceCategory'] = `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1009`;
      workInfo['sourceBusinessCategory'] = `${getTenantID()}${ILoadMapTypeAll.PROCURECLEAR_FLOWTYPE}1000`;
      workInfo['sourceRevokeState'] = `${getTenantID()}${ILoadMapTypeAll.PROCURECLARFY_STATE}1000`;
      workInfo['sourceCancelState'] = `${getTenantID()}${ILoadMapTypeAll.PROCURECLARFY_STATE}1003`;
      workInfo['sourceOrderType'] = dataInfo?.orderType || `${getTenantID()}${ILoadMapTypeAll.ALLORDER_TYPE}1012`;
      workInfo['sourceApplyFields'] = { own: 'apply', workflowType: 'category' };
      // 撤回
      workInfo['applyHeader'] = 'apply';
      workInfo['revokeRequestUrl'] = '/purchaseSourceClarifyController/invalid';
      workInfo['revokeRequestState'] = `${getTenantID()}${ILoadMapTypeAll.PROCURECLARFY_STATE}`;
      workInfo['isShowRevokeStateList'] = [`${getTenantID()}${ILoadMapTypeAll.PROCURECLARFY_STATE}1001`];
      workInfo['revokeTitle'] = dataInfo?.packName;
    } else if (currentKey == 'source-calibrate') {
      workInfo['sourceDetailInfo'] = dataInfo;
      workInfo['sourceController'] = 'purchaseSourceCalibrateController';
      workInfo['sourceCategory'] = `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1005`;
      workInfo['sourceBusinessCategory'] = `${getTenantID()}${ILoadMapTypeAll.CALIBRATE_BUSINESSTYPE}1000`;
      workInfo['sourceRevokeState'] = `${getTenantID()}${ILoadMapTypeAll?.CALIBRATE_STATE}1000`;
      workInfo['sourceCancelState'] = `${getTenantID()}${ILoadMapTypeAll?.CALIBRATE_STATE}1003`;
      workInfo['sourceOrderType'] = dataInfo?.orderType || `${getTenantID()}${ILoadMapTypeAll.ALLORDER_TYPE}1017`;
      workInfo['sourceApplyFields'] = { own: 'own', workflowType: 'category' };
      // 撤回
      workInfo['applyHeader'] = 'own';
      workInfo['revokeRequestUrl'] = '/purchaseSourceCalibrateController/invalid';
      workInfo['revokeRequestState'] = `${getTenantID()}${ILoadMapTypeAll.CALIBRATE_STATE}`;
      workInfo['isShowRevokeStateList'] = [`${getTenantID()}${ILoadMapTypeAll.CALIBRATE_STATE}1001`];
      workInfo['revokeTitle'] = dataInfo?.purchProjectName;
    }
    // saveWorkFlowConfig(workInfo);
  }

  return workInfo;
  // }, [dataInfo, currentKey]);
};

export { useWorkFlowConfig };
